import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class CopyOfDist {
	static String endFlag = ".";
	static String newLine = "\n";

	public static void main(String[] args) {
		//String path = "./";
		String path = "C:/";

		System.out.println("####### paste the classes...");
		try {
			Scanner reader = new Scanner(System.in);
			StringBuffer sb = new StringBuffer();
			String line = "";
			do {
				line = reader.next();
				sb.append(line + newLine);
			} while (!line.equals(endFlag));

			String strFile = getDistFileString();
			System.out.println("vi "+strFile+";");
						
			int count = 0;

			String[] lines = sb.toString().split(newLine);
			if (1 < lines.length) {
				//BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
			    //			new FileOutputStream(path + strFile), "EUC-KR"));
				
				BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
			    			new FileOutputStream(path + strFile)));

				System.out.println("####### writing...");
				for (int i = 0; i < lines.length; i++) {
					if (!lines[i].trim().equals(endFlag)) {
						out.write(lines[i] + newLine);
						count++;
						System.out.println(lines[i]);
					}
				}
				out.flush();
				out.close();
				System.out.println("####### " + strFile);
			}
			System.out.println("####### " + count + " line(s) writen.");
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String getDistFileString() {
		Date date = new Date();

		SimpleDateFormat all = new SimpleDateFormat("yyyyMMdd HHmmss");
		SimpleDateFormat ymd = new SimpleDateFormat("yyyyMMdd");
		SimpleDateFormat hm = new SimpleDateFormat("HHmm");

		System.out.println("current time:" + all.format(date));

		date.setTime(date.getTime() + 1000 * 60);

		String strYmd = ymd.format(date);
		String strHm = hm.format(date);

		Integer intHhmm = Integer.parseInt(strHm);

		if (intHhmm % 2 != 0) {
			date.setTime(date.getTime() + 1000 * 60);
		}

		return strYmd + "_" + hm.format(date) + ".list";

	}

}